<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myapp";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// sql to create table
$sql = array (
"CREATE TABLE IF NOT EXISTS myapp.cms_page (
     id INT NOT NULL,
     seo_key VARCHAR(225) NULL,
     title TEXT NULL,
     content LONGTEXT NULL,
     layout VARCHAR(11) NOT NULL,
     store INT(5) NOT NULL,
     status VARCHAR(8) NULL,
     created_at TIMESTAMP NULL,
     updated_at TIMESTAMP NULL,
     PRIMARY KEY (id))
ENGINE = InnoDB",
"CREATE TABLE IF NOT EXISTS myapp.product (
     id INT NOT NULL,
     name TEXT NULL,
     seo_key VARCHAR(225) NULL,
     short_description LONGTEXT NULL,
     description LONGTEXT NULL,
     sku VARCHAR(11) NOT NULL,
     price DECIMAL (15,5) NOT NULL,
     store INT(5) NOT NULL,
     status VARCHAR(8) NULL,
     visibility VARCHAR(11) NULL,
     created_at TIMESTAMP NULL,
     updated_at TIMESTAMP NULL,
     PRIMARY KEY (id))
ENGINE = InnoDB",
"CREATE TABLE IF NOT EXISTS myapp.product_customer_group_price (
     id INT NOT NULL,
     store INT(5) NOT NULL,
     customer_group INT(8) NOT NULL,
     discount_type VARCHAR(11) NOT NULL,
     discount DECIMAL(15,5) NOT NULL,
     created_at TIMESTAMP NULL,
     updated_at TIMESTAMP NULL,
     PRIMARY KEY (id))
ENGINE = InnoDB",
"CREATE TABLE IF NOT EXISTS myapp.product_customer_tier_price (
     id INT NOT NULL,
     store INT(5) NOT NULL,
     customer_group INT(8) NOT NULL,
     quantity INT(5) NOT NULL,
     discount_type VARCHAR(11) NOT NULL,
     discount DECIMAL(15,5) NOT NULL,
     created_at TIMESTAMP NULL,
     updated_at TIMESTAMP NULL,
     PRIMARY KEY (id))
ENGINE = InnoDB"
);
foreach($sql as $table){
    if ($conn->query($table) === TRUE) {
        echo "Table created successfully";
    } else {
        echo "Error creating table: " . $conn->error;
    }
}
$conn->close();
?>
